home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / misc / LEDA_high.lha / LEDA-3.1c-high / man / array2.tex < prev    next >
Encoding:
Text File  |  1994-08-05  |  1.3 KB  |  52 lines

  1. \bigskip
  2. \bigskip
  3. {\magonebf 3.2 Two Dimensional Arrays (array2)}
  4.  
  5. \decl array2 E 
  6.  
  7. {\bf 1. Definition}
  8.  
  9. An instance $A$ of the parameterized data type \name\ is a mapping from a 
  10. set of pairs $I = [a..b] \times [c..d]$, called the index set of $A$, to the 
  11. set of variables of data type $E$, called the element type of $A$, for two 
  12. fixed intervals of integers $[a..b]$ and $[b..c]$.  $A(i,j)$ is called the 
  13. element at position $(i,j)$. 
  14.  
  15. \bigskip
  16. {\bf 2. Creation}
  17.  
  18. \create A (a,b,c,d)
  19.  
  20. creates an instance \var\ of type \name\ with index set $[a..b]\times [c..d]$.
  21.  
  22.  
  23. \bigskip
  24. {\bf 3. Operations}
  25. \cleartabs
  26. \+&\hskip 1.5truecm &\hskip 6truecm &\cr
  27. \+\opf E\&  {int\ i,\ int\ j}           
  28.                             {returns $A(i,j)$. }
  29. \+\nop                      {\precond $a\le i\le b$ and $c\le j\le d$. }
  30. \smallskip
  31. \+\op  int  low1  {}        
  32.                             {returns $a$}
  33. \smallskip
  34. \+\op  int  high1 {}        
  35.                             {returns $b$}
  36. \smallskip
  37. \+\op  int  low2  {}        
  38.                             {returns $c$}
  39. \smallskip
  40. \+\op  int  high2 {}        
  41.                             {returns $d$}
  42. \smallskip
  43.  
  44.  
  45. \bigskip
  46. {\bf 4. Implementation}
  47.  
  48. Two dimensional arrays are implemented by \CC vectors. All operations
  49. take time $O(1)$, the space requirement is $O(|I|)$.
  50.  
  51.  
  52.